package com.multitrack.datatype;

import java.net.SocketTimeoutException;

public enum STATE {
	SOCKET_SUCCESS, SOCKET_FAIL, SOCKET_EXCEPTION,

	;

	public static String MESSAGE = "MESSAGE";

	static public STATE getEnum(int ordinal) {
		STATE[] list = STATE.values();
		for (int i = 0; i < list.length; i++) {
			if (list[i].ordinal() == ordinal)
				return list[i];
		}
		return null;
	}

	static public int findException(Exception exception) {
		if (exception == null) {
			return STATE.SOCKET_SUCCESS.ordinal();
		} else if (exception.equals(new SocketTimeoutException())) {
			return STATE.SOCKET_EXCEPTION.ordinal();
		} else {
			return STATE.SOCKET_FAIL.ordinal();
		}
	}
}
